package cn.wolfcode.p2p.base.service.impl;
import java.math.BigDecimal;

import cn.wolfcode.p2p.base.domain.Account;
import cn.wolfcode.p2p.base.domain.LoginInfo;
import cn.wolfcode.p2p.base.mapper.AccountMapper;
import cn.wolfcode.p2p.base.service.IAccountService;
import cn.wolfcode.p2p.util.AssertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class AccountServiceImpl implements IAccountService {
        @Autowired
        private AccountMapper accountMapper;
        @Override
        public void init(LoginInfo loginInfo) {
                Account account = new Account();
                account.setTradePassword(loginInfo.getPassword());
                account.setId(loginInfo.getId());
                accountMapper.insert(account);

        }

        @Override
        public Account query(Long id) {
                return accountMapper.selectByPrimaryKey(id);
        }

        @Override
        public Account select(Long id) {
                return accountMapper.selectByPrimaryKey(id);
        }

        @Override
        public Account getByid(Long id) {
                return accountMapper.selectByPrimaryKey(id);
        }

        @Override
        public void update(Account applierAccount) {
                int i = accountMapper.updateByPrimaryKey(applierAccount);
                AssertUtil.instance().isFalse(i<1,"账户信息修改失败!");
        }
}
